<!DOCTYPE html>

<head>
    <meta charset="utf-8">
    <script src="./vue.js"></script>
</head>

<body>
    <div id="app">
        <h1>{{ title }}</h1>
        <button @click="randomTitle()">改变</button>
        <button @click="destoryVm()">销毁实例</button>
        <div v-html="message"></div>
    </div>

    <script type="text/javascript">
        var vm = new Vue({
            el: '#app',
            data: {
                title: 'Hello World',
                message:'<h1>菜鸟教程</h1>'
            },
            methods: {
                randomTitle() {
                    this.title = 'Hello' + ['China', 'World', 'Universe'][Math.floor(Math.random() * 2.999)]
                },
                destoryVm() {
                    this.$destroy()
                },
                beforeCreate() {
                    console.log('before create')
                },
                created() {
                    console.log('created')
                },
                beforeMount() {
                    console.log('before mount')
                },
                mounted() {
                    console.log('mounted')
                },
                beforeUpdate() {
                    console.log('before update')
                },
                updated() {
                    console.log('updated')
                },
                beforeDestroy() {
                    console.log('before destroy')
                },
                destroyed() {
                    console.log('destroyed')
                }
            }
        })
    </script>
</body>